﻿using System;

namespace TK
{
    public class CustomSerializerException : Exception {
        public readonly SerializerFailType FailType;

        public CustomSerializerException(SerializerFailType type, object value, string fieldName) :
            base(string.Format(type + (string.IsNullOrEmpty(fieldName) ? "" : ", Property/Field: " + fieldName) + ", Value: " + value.GetType().FullName))
        {
            FailType = type;
        }

        public CustomSerializerException(SerializerFailType type, Type t) : base(string.Format(type + ", Type: " + t.FullName))
        {
            FailType = type;
        }
    }

    public enum SerializerFailType {
        /// <summary> detected ring in objects </summary>
        RingDetected,

        /// <summary> property/field duplicate name </summary>
        DuplicateName,

        ConvertError,
        ConverterUndefined
    }
}